#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import base64
import random
import time
from common.readelement import Element
from page_object.webpage import WebPage
from tools.logger import Log

login = Element('jzsz/app_personal/login')


class AppPersonalLoginPage(WebPage):
    """登录类"""
    def choose_personalLogin(self):
        """选择个人登录"""
        self.is_click(login['我的'])
        self.is_click(login['立即登录'])
        self.find_elements(login['劳动者'])[0].click()

    def username(self, name):
        """用户名"""
        self.find_elements(login['用户名'])[0].click()
        self.find_elements(login['用户名'])[0].send_keys(name)

    def password(self, pwd):
        """密码"""
        self.find_elements(login['用户名'])[1].click()
        self.find_elements(login['用户名'])[1].send_keys(pwd)
        self.driver.implicitly_wait(20)

    def submit(self):
        """登录"""
        self.is_click(login['登录'])

    def quit_login(self):
        """退出登录"""
        # num = self.elements_num(login['test'])
        # print('AppPersonalLoginPage', num)
        # self.find_elements(login['test'])[40].click()

        # self.is_click(login['我的'])
        self.is_click(login['设置'])
        self.is_click(login['退出登录'])
        self.is_click(login['确认'])

    def login_success(self):
        """验证登录"""
        self.is_click(login['我的'])
        return self.is_exists(login['求职意向'])





